CREATE OR REPLACE PACKAGE BODY logout AS
auth BOOLEAN;
new_pwd varchar2(255);

procedure input is
      expires_gmt date;
      expires date := sysdate-1;
begin
        if (OWA_INIT.DBMS_SERVER_GMTDIFF is not NULL)
        then
         expires_gmt := expires-(OWA_INIT.DBMS_SERVER_GMTDIFF/24);
        else
         expires_gmt := new_time(expires,OWA_INIT.DBMS_SERVER_TIMEZONE,'GMT');
        end if;

        owa_util.mime_header('text/html',false);
        htp.print('Expires: '||
                    rtrim(to_char(expires_gmt,'Day'))||
                    to_char(expires_gmt,', DD-Mon-YY HH24:MI:SS')||' GMT');
        owa_util.http_header_close;
        htp.htmlOpen;
        htp.headOpen;
        htp.title('input');
        htp.headClose;
        htp.bodyOpen;
        htp.header(1,'input');
        if auth then
      		htp.p('authorize state set to true');
        else
      		htp.p('authorize state set to false');
        end if;
        htp.formOpen('logout.alter_user');
        htp.p('Usuario:');htp.p(user);
        htp.formHidden('uname',user);htp.nl;
        htp.p('Password:');htp.formText('passwd');htp.nl;
        htp.p('Confirm Password:');htp.formText('cpasswd');htp.nl;
        htp.formSubmit;
        htp.formClose;
        htp.bodyClose;
        htp.htmlClose;
end;

procedure alter_user(uname VARCHAR2, passwd VARCHAR2, cpasswd VARCHAR2) is
      expires_gmt date;
      expires date := sysdate-1;
begin
        if (OWA_INIT.DBMS_SERVER_GMTDIFF is not NULL)
        then
         expires_gmt := expires-(OWA_INIT.DBMS_SERVER_GMTDIFF/24);
        else
         expires_gmt := new_time(expires,OWA_INIT.DBMS_SERVER_TIMEZONE,'GMT');
        end if;
        new_pwd := cpasswd;
        owa_util.mime_header('text/html',false);
        htp.print('Expires: '||
                    rtrim(to_char(expires_gmt,'Day'))||
                    to_char(expires_gmt,', DD-Mon-YY HH24:MI:SS')||' GMT');
        owa_util.http_header_close;
        htp.htmlOpen;
        htp.headOpen;
        htp.title('alter_user');
        htp.headClose;
        htp.bodyOpen;
        htp.header(1,'alter_user');
        if auth then
      		htp.p('authorize state set to true');
        else
      		htp.p('authorize state set to false');
        end if;
        htp.anchor('logout.confirm_change','continuar');
        htp.br;
        htp.anchor('logout.cancel_change','cancelar');
        htp.bodyClose;
        htp.htmlClose;
end;

procedure confirm_change is
      expires_gmt date;
      expires date := sysdate-1;
      txt varchar2(2000);
begin
        txt := 'alter user '||USER||' identified by '||new_pwd;
        execute immediate txt;
        owa_util.redirect_url('/dpls/sample/demo.startup');
end;

procedure cancel_change is
      expires_gmt date;
      expires date := sysdate-1;
begin
        owa_util.redirect_url('/dpls/sample/demo.startup');
end;

function  authorize return boolean is
   begin
      -- in authorization NONE always return true
      owa_sec.set_protection_realm('new DB Login');
      if auth then
   		    auth := false;
      		return false;
      else
   		    auth := true;
      		return true;
      end if;
   end;

begin
   auth := false;
END logout;
/
